package models

import "github.com/beego/beego/v2/client/orm"

type LatentCustomerModel struct {
	LatentCustomerID int    `json:"latentCustomerID" orm:"column(latent_customer_ID)"`
	Name             string `json:"name" orm:"column(name)"`
	Company          string `json:"company" orm:"column(company)"`
	PhoneNumber      string `json:"phoneNumber" orm:"column(phone_number)"`
	Email            string `json:"email" orm:"column(email)"`
	Origin           string `json:"origin" orm:"column(origin)"`
	LatentStatus     int    `json:"latentStatus" orm:"column(latent_status)"`
}

// GetLatentCustomerListInformation 查询潜在客户信息列表
func GetLatentCustomerListInformation(from, to int64) ([]LatentCustomerModel, int64) {
	o := orm.NewOrm()
	var latentCustomers []LatentCustomerModel
	var total int64
	num, err := o.Raw("select * from latent_customer order by latent_status limit ?,?", from, to).QueryRows(&latentCustomers)
	err = o.Raw("select count(*) from latent_customer order by latent_status").QueryRow(&total)
	if err == nil {
		return latentCustomers, total
	} else {
		return nil, num
	}
}
